package com.ship.dispatch.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ship.common.datasource.annotation.Slave;
import com.ship.dispatch.bean.SpBoastPortMessage;
import com.ship.dispatch.bean.boats.info.QueryBoatsPortDetailsInfo;
import com.ship.dispatch.bean.boats.info.QueryBoatsPortInfo;
import com.ship.dispatch.bean.boats.info.QueryBoatsPortSisterInfo;
import com.ship.dispatch.bean.boats.info.QueryPortInfo;
import com.ship.dispatch.vo.SpBoastPortMessageDetailVo;
import com.ship.dispatch.vo.SpBoastPortMessageVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface BoastPortMessageMapper extends BaseMapper<SpBoastPortMessage> {
    List<QueryBoatsPortInfo> queryBoatsPortList(@Param("shipNameList") List<String> shipNameList,
                                                @Param("imoList") List<String> imoList,
                                                @Param("portNameList") List<String> portNameList,
                                                @Param("sisterStatus") String sisterStatus);

    List<QueryPortInfo> countPortTotal(@Param("shipName") String shipName,@Param("portName") String portName,@Param("imo") String imo);

    QueryBoatsPortDetailsInfo queryBoatsPortByImo(@Param("imo") String imo);

    List<String> queryBoatsPortSisterList(@Param("shipName") String shipName,@Param("imo") String imo);

    List<SpBoastPortMessage> queryBoatsPortHistoryList(@Param("portName") String portName,@Param("imo") String imo,@Param("startDate") String startDate,@Param("endDate") String endDate);

    List<SpBoastPortMessageVo> queryBoatsPortPage(@Param("portNameChsList") List<String> portNameChsList);

    List<QueryPortInfo> countShipTotal(@Param("portNameChs") String portNameChs);

    SpBoastPortMessageDetailVo getBoastPortMessageDetail(@Param("portNameChs") String portNameChs);

    List<SpBoastPortMessage> getBoatsPortHistoryList(@Param("portNameChs")String portNameChs,@Param("shipName") String shipName,@Param("startDate") String startDate,@Param("endDate") String endDate);

    List<String> queryMessageByShipName();

    List<String> queryMessageByImo();

    List<String> queryMessageByPortName(@Param("postName") String postName);

    List<String> queryMessageByPortCode();

    @Select("SELECT id,url FROM ihs_ship_base_file WHERE port_name_chs = #{portNameChs}")
    List<Map<String,String>> getBoastPortFileMessageDetail(String portNameChs);

    @Select("SELECT id,url FROM ihs_ship_base_file WHERE port_name = #{portName}")
    List<Map<String, String>> getBoastPortFileList(@Param("portName") String portName);

    @Insert("INSERT INTO ihs_ship_base_file (id, url, port_name_chs) VALUES (#{id}, #{url}, #{portNameChs})")
    void upFile(@Param("id") String id, @Param("url") String url, @Param("portNameChs") String portNameChs);

    @Insert("INSERT INTO ihs_ship_base_file (id, url, port_name) VALUES (#{id}, #{url}, #{portName})")
    void addPortFileUrl(@Param("id") String id, @Param("url") String url, @Param("portName") String portName);

    @Select("SELECT url FROM ihs_ship_base_file WHERE id = #{id}")
    List<String> getBoatsPortFileByID(Long id);

    @Delete("DELETE FROM ihs_ship_base_file WHERE id = #{id}")
    void delBoatsPortFile(@Param("id")Long id);

    @Select("SELECT url FROM ihs_ship_base_file WHERE id = #{id}")
    String getUrlByPortNameChs(String id);

    List<QueryBoatsPortInfo> querySisterBoatsPort(@Param("sisterIdList") List<String> sisterIdList);

    List<String> queryPostNameList(@Param("postName") String postName);
}
